package amqp.tutorials.tut6;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;


@Profile({"tut6", "rpc"})
@Configuration
public class Tut6Config {

    @Profile("client")
    public static class Client {


        @Bean
        public DirectExchange directExchange() {
            return new DirectExchange("rpc");
        }

        @Bean
        public Tut6Client tut6Client() {
            return new Tut6Client();
        }
    }

    @Profile("server")
    public static class Server {


        @Bean
        public DirectExchange directExchange() {
            return new DirectExchange("rpc");
        }

        @Bean
        public Queue queue() {
            return new Queue("rpc.queue");
        }

        @Bean
        public Binding binding(DirectExchange directExchange, Queue queue) {
            return BindingBuilder.bind(queue).to(directExchange).with("rpc");
        }

        @Bean
        public Tut6Server tut6Server() {

            return new Tut6Server();
        }
    }
}
